package com.android.infantschool.ui.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.infantschool.R;

/**
 * author cowards
 * created on 2019\3\26 0026
 **/
public class DialogSignInSuccess extends Dialog {

    private Activity activity;
    private ImageView imgSignIn;
    private TextView tvSignInStatus;
    private Button btnSignInEnter;

    private OnLister lister;

    public DialogSignInSuccess(@NonNull Activity context, OnLister lister) {
        super(context, R.style.dialog_loading);
        this.activity = context;
        this.lister = lister;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        setContentView(R.layout.dialog_sign_in);
        this.setCanceledOnTouchOutside(false);//点击dialog背景部分不消失
        this.setCancelable(false);//dialog出现时，点击back键不消失
        Window window = this.getWindow();
        window.setGravity(Gravity.CENTER);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);
        initView();
    }

    private void initView() {
        imgSignIn = findViewById(R.id.img_sign_in);
        tvSignInStatus = findViewById(R.id.tv_sign_in_status);
        btnSignInEnter = findViewById(R.id.btn_sign_in_enter);
        btnSignInEnter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (lister != null) {
                    lister.lister();
                }
            }
        });
    }

    @Override
    public void dismiss() {
        super.dismiss();
    }

    public interface OnLister {
        void lister();
    }

}